package com.tv.nextin.adapter;

import java.sql.Array;
import java.util.ArrayList;

import com.tv.nextin.R;
import com.tv.nextin.bean.TimeSp;

import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class GridItemAdapter extends ArrayAdapter<TimeSp>{
	
	Context context;
	ArrayList<TimeSp> timeSps = new ArrayList<TimeSp>();

	public GridItemAdapter(Context context, ArrayList<TimeSp> timeSps) {
		super(context, R.layout.item_gridview, timeSps);
		this.context = context;
		this.timeSps = timeSps;
	}

	@Override
	public int getCount() {
		return timeSps.size();
	}

	@Override
	public TimeSp getItem(int position) {
		return timeSps.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View v, ViewGroup parent) {
		ViewHolder holder = null;
		if (v == null) {
			LayoutInflater inflater = LayoutInflater.from(getContext());
			v = inflater.inflate(R.layout.item_gridview, parent, false);

			holder = new ViewHolder();

			holder.btnTime = (Button) v.findViewById(R.id.btn_time);
			v.setTag(holder);
		} else {
			holder = (ViewHolder) v.getTag();
		}
		
		holder.btnTime.setText(timeSps.get(position).getTime());
		
		return v;
	}
	
	class ViewHolder{
		Button btnTime;
	}
	
	

}
